updating oE c_proc
c_proc
<built-in> procedure c_proc(integer rid, sequence args={})
calls a C void function, machine code function, translated Euphoria procedure, or compiled Euphoria procedure by routine id.
Parameters:
- rid : an integer, the routine_id of the external function being called.
- args : a sequence, the list of parameters to pass to the function
Errors:
If rid is not a valid routine id, or the arguments do not match the prototype of the routine being called, an error occurs.
Comments:
rid must have been returned by define_c_proc, not by routine_id. The type checks are different, and you would get a machine level exception in the best case.
If the procedure does not take any arguments then args should be {}.
If you pass an argument value which contains a fractional part, where the C void function expects a C integer type, the argument will be rounded towards zero. For example: 5.9 will be passed as 5 and -5.9 will be passed as -5.
Example 1:
atom user32, hwnd, rect integer GetClientRect -- open user32.dll - it contains the GetClientRect C function user32 = open_dll("user32.dll") -- GetClientRect is a VOID C function that takes a C int -- and a C pointer as its arguments: GetClientRect = define_c_proc(user32, "GetClientRect", {C_INT, C_POINTER}) -- pass hwnd and rect as the arguments c_proc(GetClientRect, {hwnd, rect})
See Also:
Not Categorized, Please Help
|